Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New async rosapi params module implementation #1001

Open
wants to merge 19 commits into
base: ros2
Choose a base branch
from

Conversation

bjsowa
Copy link
Collaborator

@bjsowa bjsowa commented Jan 27, 2025

Public API Changes
The set_param, get_param, and delete_param service types now include:

  • A boolean indicating whether the operation was successful.
  • An optional string explaining the reason for failure.

These changes do not break the compatibility with the current version of roslibjs client, as it will ignore these new fields. Additionally, to make it backward compatible, if get_param fails, the value field in the response will still be set to an empty JSON string.

Description
Changed the implementation of rosapi params module to take advantage of async/await feature of rclpy executor instead of creating a separate node.

Aside from the aforementioned API change, there are few implementation changes:

  • get_param_names calls list_parameters service for each node in parallel, not sequentially. This should make it much more robust, especially if the node graph is quite big.
  • all rosapi param services use ReentrantCallbackGroup which means multiple service callbacks can be processed asynchronously.
  • The helper functions from ros2param cli package are no longer used as they are not awaitable.

@bjsowa bjsowa marked this pull request as draft January 27, 2025 23:45
@bjsowa bjsowa marked this pull request as ready for review February 14, 2025 11:32
@bjsowa bjsowa requested a review from sea-bass February 14, 2025 11:32
Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good -- no major comments

from rosapi.proxy import get_nodes

from .async_helper import futures_wait_for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the fully qualified instead of relative path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

client = _node.create_client(
SetParameters,
f"{node_name}/set_parameters",
callback_group=MutuallyExclusiveCallbackGroup(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you also want this to be reentrant callback group?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for service clients as they are created only for a single service call. In fact, if I understand it correctly, using the default callback group should be also ok here but, just in case I'm wrong, I create unique callback groups for each client.

client = _node.create_client(
GetParameters,
f"{node_name}/get_parameters",
callback_group=MutuallyExclusiveCallbackGroup(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and onwards

@@ -1,4 +1,5 @@
string name
string default_value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR says that the extra response fields are non-intrusive as you can just ignore them, but removing this default value probably will affect a few users.

I think it makes sense to remove it since you're just getting a parameter, and can handle falling back to a default on the client side, but just pointing out this is another breakage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK roslibjs does not use this feature but you're right that it still may affect some users, so I restored this field.

@bjsowa bjsowa requested a review from sea-bass February 14, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants